#include "detect.h"
#include <string.h>

gboolean detect_uniproxy ()
{
	gchar* output[1];
	output[0] = malloc(16);
	gchar* commands;
	commands = "pgrep uniproxy";
	if(g_spawn_command_line_sync (commands, output, NULL, NULL, NULL)){
		if(searchn(output[0]) >= 2)	return TRUE;
		else	return FALSE;
	}
	else	perror("Detecting failed.\n");
}
gint	searchn (gchar* a)
{
	gint i=0;
	gint ret=0;
	while(i < strlen(a))
	{
		if(*(a+i) == '\n')	ret++;
		i++;
	}
	return ret;
}
